clear
%% PROBLEM
%   'EqualMinima','Himmelblau','Sixhump','ModifiedRastrigin','Vincent',
%   'Shubert','Composition','IncreasingMinima','Rastrigin','Schaffer'.
ProblemSet.FuncType = 'EqualMinima';
ProblemSet.dimension = 1;
% ProblemSet.k = [3,3,3];
% ProblemSet.BaseFunc = 3;

[d, x_bound, ObjFunc, OptSet, ~, ~, ~, MaximalBudget, FileName]...
    = problem_setting(ProblemSet);

epsilon = [0.1,0.01,0.001,0.0001];
%% problem
Problem.Dimension = d; % the dimension of the decision variable
Problem.LowerBound = x_bound(1,:); % the lower bound of the decision variable
Problem.UpperBound = x_bound(2,:); % the upper bound of the decision variable
Problem.ObjFunc = ObjFunc;  % the objective function
%% ALGORITHM
Algorithm.PopulationSize = 500;  % the population size of the ga
Algorithm.MaxFEs = MaximalBudget;
Algorithm.CutRatio = 0.1;
Algorithm.MaxGenerationNum = ceil(MaximalBudget*0.5/Algorithm.PopulationSize);
%% OPTIMIZATION
rep = 100;
OptNoFound = zeros(rep,length(epsilon));
Times = zeros(rep,length(epsilon));
%%
for iepsilon = 1:length(epsilon)
	OptSet.epsilon = epsilon(iepsilon);
    for i = 1:rep
        disp(['epsilon: ',num2str(epsilon(iepsilon)),', replication: ',num2str(i),'.'])
        time_start = tic;
        [~, ~, ~, OptSetRemain]...
            = emommo_test(Problem, Algorithm, OptSet);
        Times(i,iepsilon) = toc(time_start);
        disp(['time used: ',num2str(Times(i,iepsilon)),'.'])
        OptNoFound(i,iepsilon) = size(OptSetRemain,1);
    end
end
%%
% save(FileName)
